#!/usr/bin/python
# -*- coding: utf-8 -*-

# import os
# import time
# # 跑马灯
# def main():
#     content = '北京欢迎你为你开天辟地'
#     while True:
#         print(content)
#         # 清理屏幕输入
#         os.system('cls') # os.system('clear')
#         content = content[1:] + content[0]
#         # 休眠200毫秒
#         time.sleep(0.2)
# 
# if __name__ == '__main__':
#     main()


# import random
# # 返回指定长度验证码
# def generate_code(code_len=4):
#     # 10+26+26
#     all_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
#     code = ''
#     for _ in range(code_len):
#         index = random.randint(0,len(all_chars)-1)
#         code += all_chars[index]
#     return code

# for _ in range(5):
#     print(generate_code(4))

# 返回指定文件名的后缀名
# def get_suffix(filename,has_dot=False):
#     """
#     :param filename:文件名
#     :param has_dot:返回的后缀名是否需要带点
#     """
#     pos = filename.rfind('.')
#     if 0 < pos < len(filename)-1:
#         index = pos if has_dot else pos + 1
#         return filename[index:]
#     else:
#         return ''

# a = get_suffix('aaaaa')
# print(a)
# a = get_suffix('aaa.txt')
# print(a)
# a = get_suffix('aaa.txt',True)
# print(a)

# 返回传入列表中最大和第二大的值
# def max2(x):
#     m1,m2 = (x[0],x[1]) if x[0] > x[1] else (x[1],x[0])
#     for index in range(2,len(x)):
#         if x[index] > m1:
#             m2 = m1
#             m1 = x[index]
#         elif x[index] > m2:
#             m2 = x[index]
#     return m1,m2
# a = max2([3,2,44,5,1,23,111])
# print(a)

# 计算指定的年月日时这一年的第几天
def is_leap_year(year):
    """
    判断是不是闰年
    """
    return year % 4 == 0 and year % 100 != 0 or year % 400 == 4

def which_day(year,month,day):
    days_of_month = [
        [31,28,31,30,31,30,31,31,30,31,30,31],
        [31,29,31,30,31,30,31,31,30,31,30,31]
    ][is_leap_year(year)]
    total = day
    for index in range(month-1):
        total += days_of_month[index]
    return total

def main():
    print(which_day(2019,4,3))

if __name__ == '__main__':
    main()

# 双色球选号

# from random import randint,sample

# def display(balls):
#     str1 = ''
#     for index,ball in enumerate(balls):
#         if index == len(balls)-1:
#             str1 += '| '
#         str1 += str(ball)
#         if index != len(balls)-1:
#             str1 += ', '
#     print(str1)

# def random_select():
#     red_balls = [x for x in range(1,34)]
#     select_balls = []
#     select_balls = sample(red_balls,6)
#     select_balls.sort()
#     select_balls.append(randint(1,16))
#     return select_balls

# def main():
#     n = int(input('机选几注：'))
#     for _ in range(n):
#         display(random_select())

# if __name__ == '__main__':
#     main()

# 约瑟夫环问题
# def main():
#     persons = [True] * 30
#     counter, index, number = 0, 0, 0
#     while counter < 15:
#         if persons[index]:
#             number += 1
#             if number == 9:
#                 persons[index] = False
#         index += 1
#         index %= 30

# if __name__ == '__main__':
#     main()




# 井字棋游戏
# import os

# def print_board(board):
#     print(board['1'] + '|' + board['2'] + '|' + board['3'])
#     print('-+-+-')
#     print(board['4'] + '|' + board['5'] + '|' + board['6'])
#     print('-+-+-')
#     print(board['7'] + '|' + board['8'] + '|' + board['9'])

# def main():
#     init_board = {
#         '1' : ' ','2' : ' ','3' : ' ',
#         '4' : ' ','5' : ' ','6' : ' ',
#         '7' : ' ','8' : ' ','9' : ' '
#     }
#     begin = True
#     while begin:
#         curr_board = init_board.copy()
#         counter = 0
#         turn = 'x'
#         begin = False
#         while counter < 9:
#             print_board(curr_board)
#             move = input('轮到%s走棋，请输入:')
#             os.system('cls')
#             if curr_board[move] == ' ':
#                 curr_board[move] = turn
#                 if turn == 'x':
#                     turn = 'o'
#                 else:
#                     turn = 'x'
#             os.system('clear')
#             print_board(curr_board)
#             counter += 1
#         choice = input('在玩一局(yes|no)') == 'yes'
#         begin = choice

# if __name__ == '__main__':
#     main()